#include "hplcqinfinesendcommonpacket.h"
#include "hplcqinfinepfcid.h"
#include "hplcqinfineprotocolcommondata.h"
#include "hplcqinfinemakepacket.h"

namespace hplc
{
namespace qinfine
{

HplcQinfineSendCommonPacket::HplcQinfineSendCommonPacket(HplcQinfineProtocolCommonData &data, QObject *parent)
    : BaseSendPacket (data, parent)
{
    m_d = &data;
}

HplcQinfineSendCommonPacket::~HplcQinfineSendCommonPacket()
{

}

void HplcQinfineSendCommonPacket::setDeviceAddress(quint8 address)
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makeGlobalPacket(SET_PFC(PFC_GLOBAL_DEVICE_ADDRESS), address);
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getDeviceAddress()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makeGlobalPacket(GET_PFC(PFC_GLOBAL_DEVICE_ADDRESS));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getSoftwareVersion()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_SOFTWARE_VERSION));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getHardwareVersion()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_HARDWARE_VERSION));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getProductDate()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_PRODUCT_DATE));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getSerialNumber()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_SERIAL_NUMBER));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getModel()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_MODEL));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getUsedTime()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_USED_TIME));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::setSyncTime(quint32 time)
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_SYNC_TIME), time);
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getSyncTime()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_SYNC_TIME));
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getInput(quint8 inputNum)
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_INPUT), inputNum);
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::setOutput(quint8 outputNum, quint8 level)
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_OUTPUT), outputNum, level);
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::getOutput(quint8 outputNum)
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_OUTPUT), outputNum);
    m_d->m_checker->sendRetry();
}

void HplcQinfineSendCommonPacket::setTick()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_TICK));
    m_d->m_checker->sendNoRetry();
}

void HplcQinfineSendCommonPacket::getSystemError()
{
    HplcQinfineProtocolCommonData *m_d = static_cast<HplcQinfineProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_ERROR));
    m_d->m_checker->sendRetry();
}

} // qinfine
} // hplc
